
require "Makeup1.lua"
require "Makeup2.lua"
require "Makeup3.lua"
require "palace.lua"

g_PreRes = nil
node = {}
--call once when scene loaded
function initialize(scene)
  g_PreRes = scene:getResolution()
  local kuruEngineInstance = KuruEngine.getInstance()
  kuruFaceDetector = KuruFaceDetectorExtension.cast(kuruEngineInstance:getExtension("KuruFaceDetector"))
  kuruTouch = KuruTouchExtension.cast(kuruEngineInstance:getExtension("KuruTouch"))
  kuruTouch:getTouchDownEvent():addEventHandler(onTouchDown)

  makeup1 = Makeup1:new(scene)
  makeup1:Clear()
  makeup2 = Makeup2:new(scene)
  makeup2:Clear()
  makeup3 = Makeup3:new(scene)
  makeup3:Clear()
 

  sampler1 = makeup1:getSampler()
  sampler2 = makeup2:getSampler()
  sampler3 = makeup3:getSampler()
  g_palace =PalaceEffect:init(scene, EffectType.effectType_3x1, false)
  g_palace:add(sampler1, 1)
  g_palace:add(sampler2, 2)
  g_palace:add(sampler3, 3)
  g_palace:commit()
  g_palace:isShowEnabled(true)
end

--call every frame,elapsed time is the time elapsed this frame
function frameReady(scene, elapsedTime)
end

--call when reset scene,e.g switch to rear camera
function reset(scene)
end

--call when scene close
function finalize(scene)
  kuruTouch:getTouchDownEvent():removeEventHandler(onTouchDown)
end

--call when touch screen
function onTouchDown(event)
  print("touchdown")
end

function addNodeAndRelease(scene, node)
  scene:addNode(node)
  node:release()
  return node
end

function addChildAndRelease(parent, child)
  parent:addChild(child)
  child:release()
  return child
end
